package com.woniuxy.project115.kaer.mall.controller;


import com.woniuxy.project115.kaer.commons.util.JwtUtil;
import com.woniuxy.project115.kaer.commons.util.Result;
import com.woniuxy.project115.kaer.mall.service.RefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyc
 * @since 2025年02月26日
 */
@RestController
@RequestMapping("/refund")
@Api(tags = "退款接口")
public class RefundController {
    @Resource
    private RefundService refundService;
    //用户申请退款
    @ApiOperation("退款申请")
    @PostMapping("refundApply")
    public Result refundApply(String orderNum, String reason, @RequestHeader String token) throws Exception {
        refundService.refundApply(orderNum,reason, JwtUtil.getUserId(token));
        return Result.succeed("退款申请成功", null);
    }
    //平台账户查询退款列表
    @ApiOperation("退款列表")
    @GetMapping("refundList")
    public Result refundList() {
        return Result.succeed("退款列表",refundService.refundList());
    }
    //平台账户审核退款
    @ApiOperation("审核退款")
    @PostMapping("refundAudit")
    public Result refundAudit(Integer refundId,String reason, String operate) throws Exception {
        refundService.refundAudit(refundId,reason,operate);
        return Result.succeed("审核成功", null);
    }
}

